/*==============================================================*/
/* DBMS name:      Microsoft SQL Server 2005                    */
/* Created on:     2011/7/7 18:58:21                            */
/*==============================================================*/


if exists (select 1
   from sys.sysreferences r join sys.sysobjects o on (o.id = r.constid and o.type = 'F')
   where r.fkeyid = object_id('SCms_Article') and o.name = 'FK_ART_REFERENCE_CHANNEL')
alter table SCms_Article
   drop constraint FK_ART_REFERENCE_CHANNEL
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Admin')
            and   type = 'U')
   drop table SCms_Admin
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Article')
            and   type = 'U')
   drop table SCms_Article
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Channel')
            and   type = 'U')
   drop table SCms_Channel
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Downloads')
            and   type = 'U')
   drop table SCms_Downloads
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_FeedBack')
            and   type = 'U')
   drop table SCms_FeedBack
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Links')
            and   type = 'U')
   drop table SCms_Links
go

if exists (select 1
            from  sysobjects
           where  id = object_id('SCms_Logs')
            and   type = 'U')
   drop table SCms_Logs
go

/*==============================================================*/
/* Table: SCms_Admin                                            */
/*==============================================================*/
create table SCms_Admin (
   Id                   int                  identity,
   UserName             varchar(30)          null,
   UserPwd              varchar(50)          null,
   NickName             varchar(30)          null,
   UserEmail            varchar(30)          null,
   IsLock               int                  not null,
   AddTime              datetime             null,
   constraint PK_SCMS_ADMIN primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_Article                                          */
/*==============================================================*/
create table SCms_Article (
   Id                   int                  not null,
   ChannelId            int                  null,
   Author               varchar(30)          null,
   Source               varchar(30)          null,
   KeyWords             varchar(100)         null,
   Abstract             varchar(200)         null,
   Content              ntext                null,
   Click                int                  null,
   IsLock               int                  not null,
   IsHot                int                  not null,
   AddTime              datetime             null,
   constraint PK_SCMS_ARTICLE primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_Channel                                          */
/*==============================================================*/
create table SCms_Channel (
   Id                   int                  identity,
   Name                 varchar(30)          null,
   constraint PK_SCMS_CHANNEL primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_Downloads                                        */
/*==============================================================*/
create table SCms_Downloads (
   Id                   int                  identity,
   FileName             varchar(100)         null,
   FileType             varchar(30)          null,
   FileSize             int                  null,
   FilePath             varchar(200)         null,
   Click                int                  null,
   IsLock               int                  not null,
   AddTime              datetime             null,
   constraint PK_SCMS_DOWNLOADS primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_FeedBack                                         */
/*==============================================================*/
create table SCms_FeedBack (
   Id                   int                  identity,
   UserName             varchar(30)          null,
   UserQQ               varchar(30)          null,
   Title                varchar(50)          null,
   Content              varchar(1000)        null,
   AddTime              datetime             null,
   IsLock               int                  not null,
   ReContent            varchar(1000)        null,
   ReTime               datetime             null,
   constraint PK_SCMS_FEEDBACK primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_Links                                            */
/*==============================================================*/
create table SCms_Links (
   Id                   int                  identity,
   LinkName             varchar(30)          null,
   WebUrl               varchar(200)         null,
   ImageUrl             varchar(200)         null,
   IsImage              int                  not null,
   IsLock               int                  not null,
   AddTime              datetime             null,
   constraint PK_SCMS_LINKS primary key (Id)
)
go

/*==============================================================*/
/* Table: SCms_Logs                                             */
/*==============================================================*/
create table SCms_Logs (
   Id                   int                  identity,
   LogContent           varchar(200)         null,
   AddTime              datetime             null,
   constraint PK_SCMS_LOGS primary key (Id)
)
go

alter table SCms_Article
   add constraint FK_ART_REFERENCE_CHANNEL foreign key (ChannelId)
      references SCms_Channel (Id)
go

